import {createSlice} from "@reduxjs/toolkit";
import localStoreHelper from "../../utils/LocalStoreHelper";

const initialState = {
    user:localStoreHelper.getItem("user"),
}

export const userSlice = createSlice({
    name: 'user',
    initialState:initialState,
    reducers:{
        login:(state, action)=>{
            state.user = action.payload.user;
            console.log(state,action)
        },
        logout:(state, action)=>{
            state.user = null;
        }
    }
})

export const { login, logout} = userSlice.actions;
export const actions = userSlice.actions;
const userReducer =  userSlice.reducer;
export default userReducer;